﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>集团计划</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="../../static/css/font.css" rel="stylesheet" />
    <link href="../../static/css/weadmin.css" rel="stylesheet" />
    <link href="../../../lib/layui/css/layui.css" rel="stylesheet" />
    <script src="../../../lib/layui/layui.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-collapse" lay-accordion lay-filter="infos_form">
                        <div class="layui-colla-item">
                            <h2 class="layui-colla-title">筛选条件</h2>
                            <div class="layui-colla-content">
                                <div class="layui-form layui-form-pane">
                                    <!--计划名称-->
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">计划名称</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="计划名称" id="CPName" name="CPName" class="layui-input" maxlength="50" />
                                        </div>
                                    </div>

                                    <!--时间-->
                                    <div class="layui-form-item">
                                        <!--<label class="layui-form-label">计划编号</label>
                                        <div class="layui-input-inline">
                                            <input type="text" placeholder="计划编号" class="layui-input" maxlength="8" />
                                        </div>-->
                                        <div class="layui-inline">
                                            <label class="layui-form-label">起始时间</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" id="StartDateTime" name="StartDateTime" />
                                            </div>
                                            <label class="layui-form-label layui-form-label-inner layui-form-label-inner-w1">至</label>
                                            <div class="layui-input-inline layui-form-label-inner">
                                                <input type="text" class="layui-input" id="EndDateTime" name="EndDateTime" />
                                            </div>
                                        </div>
                                    </div>


                                    <div class="layui-form-item">

                                    </div>
                                    <!--计划描述-->
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">计划内容</label>
                                        <div class="layui-input-block">
                                            <textarea  placeholder="计划内容" id="CPDescribe" name="CPDescribe" class="layui-textarea" maxlength="500"></textarea>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>

                </div>
                <div class="layui-card-header layui-btn-container">
                    <button type="button" class="layui-btn layui-btn-primary" id="find"><i class="layui-icon">&#xe615;</i>查询</button>
                    <button type="button" class="layui-btn layui-btn-primary" id="reset"><i class="layui-icon">&#xe669;</i>清空</button>
                </div>
            </div>


        </div>
    </div>
    <div class="layui-fluid" id="infos">
        <table id="dataList" lay-filter="dataList"></table>
    </div>
    <script>
        var selectCurrentID = 0;// 当前选中的 id  [用于修改]
        var selectCurrentName = "";//选择当前信息的name 
        var selectdata = function () {
            var data = {
                RefID: selectCurrentID,
                RefName: selectCurrentName,
                CPID:selectCurrentID
            }
            return data;
        };
        layui.use(['form', 'laydate', 'table', 'jquery', 'element'], function () {
            var laydate = layui.laydate;
            var $ = layui.jquery;
            var th = $(document).height();
            var table = layui.table;
            var form = layui.form;
            var element = layui.element;
            laydate.render({
                elem: '#StartDateTime', trigger: 'click'
            });
            laydate.render({
                elem: '#EndDateTime', trigger: 'click'
            });
            function PageInit() {
                var obj = $("div[lay-id='dataList']");
                var child = $(".layui-table-body");
                var off = obj.offset().top;
                var c = th - off - 100;
                child.attr("style", "height:" + c + "px");
            }
            element.on('collapse(infos_form)', function (data) {
                PageInit();
            });
            function showList() {
                var swhere = JSON.stringify({ CPName: $("#CPName").val(), CPDescribe: $("#CPDescribe").val(), StartDateTime: $("#StartDateTime").val(), EndDateTime: $("#EndDateTime").val(), IsUse: "1" });
                table.render({
                    elem: '#dataList'
                    , url: ApiUrl + 'CorpPlan/Search'
                    , headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    page: true
                    , cols: [[
                        { field: 'CPID', title: '编号', sort: true, hide: true },
                        { field: 'CPName', title: '名称', width: 300 },
                        { field: 'CPDescribe', title: '内容', width: 300 },
                        {
                            field: 'StartDateTime', title: '开始时间', width: 120, templet: function (d) {
                                return d.StartDateTime.substring(0, 10);
                            },
                        },
                        {
                            field: 'EndDateTime', title: '结束时间', width: 120, templet: function (d) {
                                return d.EndDateTime.substring(0, 10);
                            },
                        },
                        { field: 'DesignUserName', title: '制订人', width: 100 },
                        { field: 'IsCheck', title: '审核', width: 100, templet: function (d) { return d.IsCheck == "0" ? "未审核" : "已审核" } },
                        {
                            field: 'IsRelease', title: '发布', width: 100, templet: function (d) {
                                return d.IsRelease == "0" ? "未发布" : "已发布";
                            }
                        },
                        { field: 'IsUse', title: '使用状态', width: 100, templet: function (d) { return d.IsUse == "0" ? "未使用" : "使用中" }, hide: true }
                    ]]
                    , where: { swhere: swhere }
                    , parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    page: true,
                    done: function (res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                    }
                });
            };
            showList();
            $(function () {
                $("#sreach").click(function () {
                    showList();
                })
            })
            PageInit();
            function clearForm() {
                $("textarea").val("");
                $("input").val("");
            }
            //展示一条信息
            function GetSingleInfo(data) {
                $("#CPName").val(data.CPName);
                $("#CPDescribe").val(data.CPDescribe);
                $("#StartDateTime").val(data.StartDateTime.split('T')[0]);
                $("#EndDateTime").val(data.EndDateTime.split('T')[0]);
                //$("#CPID").val(data.CPID);
                //$("#IsCheck").val(data.IsCheck);
                //$("#IsRelease").val(data.IsRelease);
            }
            ///按钮操作 开始 
            //监听行单击事件（单击事件为：rowDouble）
            table.on('row(dataList)', function (obj) {
                var objtr = $(obj.tr.selector);
                $(".layui-table-body tr").attr("style", "");
                objtr.attr("style", "background:#00CC66;");
                    selectCurrentID = obj.data.CPID;
                    selectCurrentName = obj.data.CPName;
                    GetSingleInfo(obj.data);
            });


            $("#reset").click(function () {
                clearForm();
            });
            $("#find").click(function () {
                selectCurrentID = 0;
                selectCurrentName = "";
                showList();
            });
        });
    </script>
</body>
</html>